function savePerson(item){
	var vo=$(item).parent().html();
	var indexId=parseInt($("#savePersons span:last").attr("indexId"));
	indexId=indexId+1;
	$("<span indexId=\""+indexId+"\">"+vo+"</span>").insertAfter($("#savePersons span:last"));
	var inputs=$("#savePersons span:last").children("input[type='text']");
	$(inputs).each(function(){
		var replaceP="personList["+indexId+"]";
		var orginalP=$(this).attr("name");
		$(this).attr("name",orginalP.replace(/personList\[\d\]/,replaceP));
	});
};

function deletePerson(item){
	if($("#savePersons span").length>1){
		var indexId= $(item).parent().attr("indexId");
		$("span:gt("+indexId+")").each(function(){
			var next_indexId=parseInt($(this).attr("indexId"))-1;
			$(this).attr("indexId",next_indexId);
			var inputs=$(this).children("input[type='text']");
			$(inputs).each(function(){
				var replaceP="personList["+next_indexId+"]";
				var orginalP=$(this).attr("name");
				$(this).attr("name",orginalP.replace(/personList\[\d\]/,replaceP));
			});
		});
		$(item).parent().remove();
	}
}

